from rest_framework.views import APIView
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from dhm.models.Warehousing_System.administrator.administrator import Administrator

class LoginView(APIView):
    permission_classes=[IsAuthenticated]
    def get(self, request):
        user = request.user
        administrator = Administrator.objects.get(user=user)
        return Response({
            'result': "success",
            'id': user.id,
            'username': administrator.username,
            'photo': administrator.photo,
            'phone_number': administrator.phone_number,
            'creation_time': administrator.creation_time,
            'update_time': administrator.update_time,
            'verification_code': administrator.verification_code,
            'professional_title': administrator.professional_title,
        })
